package com.jacocotest.demo;

import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class IndexController {

    @PostMapping("/add")
    public String add(@RequestParam(value = "x", defaultValue = "1") double x,
                      @RequestParam(value = "y", defaultValue = "1") double y) {
        if (x <= 0 || y <= 0){
            return "不能小于0";
        }
        if (x > 9999 || y > 9999) {
            return "不能大于9999";
        }
        return "本次求和结果是: " + (x + y);
    }

    @GetMapping("/list")
    public String list(){
        return "欢迎来到加减乘除";
    }

    @PostMapping("/delete")
    public String delete(@RequestParam(value = "x", defaultValue = "1") Integer x,
                      @RequestParam(value = "y", defaultValue = "1") Integer y) {
        if (x < y){
            return "x不能小于y";
        }
        return "本次相减结果是: " + (x - y);
    }
}
